//
//  UserCenterBtn.m
//  SinaWebo
//
//  Created by wwj on 16/6/29.
//  Copyright © 2016年 亦心. All rights reserved.
//

#import "UserCenterBtn.h"
#import "Pic.h"
#import <UIButton+WebCache.h>

@implementation UserCenterBtn

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self initView];
    }
    return self;
}

- (instancetype)initWithCoder:(NSCoder *)coder{
    self = [super initWithCoder:coder];
    if (self) {
        [self initView];
    }
    return self;
}

- (void)initView{
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    [self setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
    self.titleLabel.font = [UIFont systemFontOfSize:14.0];
}

- (void)setHighlighted:(BOOL)highlighted{}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.titleLabel.height = 25;
    self.imageView.x = 0;
    self.imageView.y = 0;
    self.imageView.width = self.width;
    self.imageView.height = self.height - self.titleLabel.height;
    
    self.titleLabel.x = 0;
    self.titleLabel.y = self.imageView.height;
    self.titleLabel.width = self.width;
    
}

- (void)setPic:(Pic *)pic{
    [self sd_setImageWithURL:[NSURL URLWithString:pic.pic_big] forState:UIControlStateNormal];
    [self setTitle:pic.desc1?pic.desc1:pic.title forState:UIControlStateNormal];
}

@end
